package com.imooc.set;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class DictionaryDemo {

    public static void main(String[] args) {
        Map<String,String> animal = new HashMap<String,String>();//定义hashMap对象
        Scanner console = new Scanner(System.in);
        int i=0;
        while(i<3){
            System.out.println("输入key");
            String key=console.next();
            System.out.println("输入value");
            String value = console.next();
            animal.put(key,value);
            i++;
        }

        System.out.println("****************");
        //使用迭代器输出所有value
        Iterator<String> it = animal.values().iterator();//values()方法返回值是一个集合然后再调用集合的迭代器方法，将值存放在迭代器中
        while (it.hasNext()){
            System.out.println(it.next());
        }

        //打印key和value的值

    }

}
